package test19.transformation;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class OutputStreamWriter_ {
    //演示 OutputStreamWriter 使用
    //把FileOutputStream 字节流，转成字符流 OutputStreamWriter
    //指定处理的编码 gbk/utf-8/utf8
    public static void main(String[] args) throws IOException {
        String filePath = "d:\\a.txt";
        OutputStreamWriter gbk = new OutputStreamWriter(new FileOutputStream(filePath,true), "gbk");
        BufferedWriter bufferedWriter = new BufferedWriter(gbk);
        bufferedWriter.write("你好北京");
        bufferedWriter.close();
        System.out.printf("文件保存成功");
    }
}
